package net.haiyue.api.service;

import net.haiyue.api.entity.Event;
import net.haiyue.api.entity.SelectInfo;
import net.haiyue.api.entity.viewModel.EventViewModel;
import net.haiyue.api.entity.viewModel.EventViewModel4Request;
import net.haiyue.api.repository.EventRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class EventService {
    @Resource
    private EventRepository _repository;

    public  List<EventViewModel> all(EventViewModel4Request param){
        return _repository.all(param.getPid(),
                param.getMid(),param.getTime_begin(),
                param.getTime_end(),param.getEmail());
    }

    public Event add(Event event){
        return _repository.save(event);
    }

    public Event singleById(Integer id){
        return _repository.findEventById((long)(id.intValue()));
    }

    public List<SelectInfo> selectModule(String email,Integer id){
        return _repository.selectModule(email,id);
    }

    public void  del(Integer id){
        _repository.deleteById(id);
    }
}
